package com.inspinia.base.api.model;


import com.inspinia.base.common.exception.ApiErrorCode;

/**
 * api的异常
 * Created by veblen on 2017/7/5.
 */
public class ApiException extends RuntimeException {
    /**
     * 异常代码
     */
    private int errorCode;
    /**
     * 异常信息
     */
    private String message;

    public ApiException(int errorCode, String message) {
        super("{\"errorCode\":" + errorCode + ",\"msg\":\"" + message + "\"}");
        this.errorCode = errorCode;
        this.message = message;
    }

    public ApiException(ApiErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getName());
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
